"""RFB security types as states implementation."""

class _SecBase(object):
    """Abstract security base object."""

    # given fields must be set in subclasses
    id = None
    name = None

     # (do not override if auth is not supported)
    supported = False

    # supported security objects with greater priority
    # will be given to server as security methods that have
    # higher priority
    priority = None

    def __call__(self, *args, **kwargs):
        raise NotImplemetedError

class Invalid(_SecBase):

    id = 0
    name = "Invalid"

class NoneAuth(_SecBase):

    id = 1
    name = "None"
    supported = True
    priority = 1

    def __call__(self, client):
        # no auth is actually perfromed
        return client.getState("onAuthCompleted")

class VncAuth(_SecBase):

    id = 2
    name = "VNC"

class Ra2(_SecBase):

    id = 5
    name = "RA2"

class Ra2ne(_SecBase):

    id = 6
    name = "RA2ne"

class TightAuth(_SecBase):

    id = 16
    name = "Tight"

class UltraAuth(_SecBase):

    id = 17
    name = "Ultra"

class TlsAuth(_SecBase):

    id = 18
    name = "TLS"

class VeNCryptAuth(_SecBase):

    id = 19
    name = "VeNCrypt"

authTypes = (
    Invalid,
    NoneAuth,
    VncAuth,
    Ra2, Ra2ne,
    TightAuth,
    UltraAuth,
    TlsAuth,
    VeNCryptAuth
)

# vim: set sts=4 sw=4 et :
